package com.example.prison.mapper;

import com.example.prison.entity.SpecialInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
* @author jiang
* @description 针对表【special_Info】的数据库操作Mapper
* @createDate 2024-07-09 11:25:05
* @Entity com.example.prison.entity.SpecialInfo
*/
@Mapper
public interface SpecialInfoMapper extends BaseMapper<SpecialInfo> {

    @Select("<script>select * from special_Info " +
            " <where> " +
            " <if test=\"specialPost != null and specialPost != ''\">and special_post like concat('%',#{specialPost},'%') </if> " +
            " </where> " +
            "order by id desc</script>")
    List<SpecialInfo> get(@Param("specialPost")String specialPost);

    @Select("<script>select * from special_Info order by id desc</script>")
    List<SpecialInfo> list();

    @Insert("insert into special_Info(special_post, request_number) " +
            "values (#{specialPost}, #{requestNumber})")
    int add(SpecialInfo data);

    @Delete("<script>delete from special_Info where id in <foreach collection=\"ids\" item=\"item\" open=\"(\" separator=\",\" close=\")\">#{item} </foreach> </script>")
    void deleting(@Param("ids") Integer[] ids);

    @Update({"<script> UPDATE special_Info",
            "<set>",
            "<if test='data.specialPost != null'>special_post = #{data.specialPost},</if>",
            "<if test='data.requestNumber != null'>request_number = #{data.requestNumber},</if>",
            "</set>",
            "where id = #{id} </script>"})
    int updating(SpecialInfo data,Integer id);

    @Select("select * from special_Info where id=#{id}")
    SpecialInfo getById(@Param("id") Integer id);

    @Select("select * from special_Info where special_post=#{specialPost}")
    List<SpecialInfo> getByPost(@Param("specialPost") String specialPost);

}




